package org.ax.controller.plan;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.ax.data.Result;
import org.ax.pojo.plan.Manufacture;
import org.ax.pojo.plan.Order;
import org.ax.service.plan.ManufactureService;
import org.ax.service.plan.OrderService;
import org.ax.service.process.TechnologyService;
import org.ax.service.process.imple.ITechnologyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-26-21:38
 */
@RequestMapping("/manufacture")
@RestController
public class ManufactureController {
    @Autowired
    ManufactureService manufactureService;
    @Autowired
    Result result;
    @RequestMapping("/find")
    public ModelAndView find(){return new ModelAndView("plan/manufacture");}
    @GetMapping("/list")
    public Result search(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int limit){
        Page<Manufacture> manufacturePage = manufactureService.searchManufacturePage(new Page(page, limit));
        result.setData(manufacturePage.getRecords());
        result.setCount(manufacturePage.getTotal());
        return result;
    }
    @PostMapping("/addManufacture")
    public Result addManufacture(Manufacture manufacture){
        result.setMsg(manufactureService.addManufacture(manufacture)?"添加成功":"添加失败");
        return result;
    }
    @PostMapping("/updateManufacture")
    public Result updateManufacture(Manufacture manufacture){
        result.setMsg(manufactureService.updateManufacture(manufacture)?"修改成功":"修改失败");
        return result;
    }
    @GetMapping("/patchDel")
    public Result patchDel(String[] ids){
        result.setMsg(manufactureService.deletesManufacture(ids)?"删除成功":"删除失败");
        return result;
    }
//    列出所有的订单
    @Autowired
    OrderService orderService;
    @GetMapping("/orderList")
    public Result orderList(){
        result.setData(orderService.findOrderList());
        return result;
    }
    @Autowired
    TechnologyService technologyService;
    @GetMapping("/technologyList")
    public Result technologyList(){
        result.setData(technologyService.findTechnologyList());
        return result;
    }
    @GetMapping("/manufactureList")
    public Result manufactureList(){
        result.setData(manufactureService.searchManufactures());
        return result;
    }
}
